﻿using System;
using System.Collections.Generic;

using System.Text;
using WCSY.MODEL;
using System.Data;

namespace WCSY.DAL
{
    public static class WarningService
    {
        public static void addWarning(Warning war) {
            string sql = @"insert into warning(descript,fillpsn,isdo,doPsn,inDate) values('" + war.Descript + "','" + war.FillPsn + "'," + war.IsDo + ",'" + war.DoPsn + "',convert(varchar(100),getdate(),23))";
            //DBHelper db = new DBHelper();
            
            DBHelper.ExecuteCommand(sql);
        
        }

        public static void updateWarning(int id) {
            string sql = @"update warning set isdo=1 where id="+id+"";
            DBHelper.ExecuteCommand(sql);
        
        }

        public static DataTable secAllWarning() {
            string sql = @"select * from warning";
            return DBHelper.GetDataSet(sql);

        
        }

        public static DataTable secWarningByDate()
        {
            string sql = @"select * from warning where indate >convert(varchar(100),getdate()-2,23) and isdo=0";
            return DBHelper.GetDataSet(sql);


        }
    }
}
